function [out, data, depths] = gUnpivot(dates, data, depths)
%GUNPIVOT Unpivots table data moving the depths into a column vector
%   Detailed explanation goes here

    out = [];
    for i=1:length(depths)
        out = vertcat(out,[dates(1:end,1) ones(size(data,1),1)*depths(i) data(1:end,i)]);
    end

    if(nargout==1)
       %do nothing
    elseif(nargout==3)
        depths = out(:,2);
        data = out(:,3);
        out = out(:,1);
    end

end

